//
//  HYCRecommendCell.m
//  FamilyTravel
//
//  Created by dllo on 15/10/21.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HYCRecommendCell.h"
#import "HYCRecommendMovie.h"
#import <UIImageView+WebCache.h>
#define WIDTH self.contentView.frame.size.width
#define HEIFGT self.contentView.frame.size.height




@implementation HYCRecommendCell
- (void)dealloc {
    [_view release];
    [_tuImageView release];
    [_aimLable release];
    [_discountLable release];
    [_moneylable release];
   
    
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell {
    self.view = [[UIView alloc] init];
//        self.view.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.view];
//    self.view.layer.borderWidth = 1;
//    self.view.layer.cornerRadius = 10;
    [_view release];
    
    self.tuImageView = [[UIImageView alloc] init];
    [self.view addSubview:self.tuImageView];
    self.tuImageView.backgroundColor = [UIColor yellowColor];
    self.tuImageView.layer.borderWidth = 1;;
    self.tuImageView.layer.cornerRadius = 10;
    self.tuImageView.layer.masksToBounds = YES;
    [_tuImageView release];
    
    self.aimLable = [[UILabel alloc] init];
    [self.view addSubview:self.aimLable];
    [_aimLable release];
    self.aimLable.font = [UIFont systemFontOfSize:15];
    self.aimLable.numberOfLines = 0;
    //自适应
    [self.aimLable sizeToFit];
//    self.aimLable.backgroundColor = [UIColor whiteColor];
    
    
    self.discountLable = [[UILabel alloc] init];
    [self.view addSubview:self.discountLable];
    [_discountLable release];
    self.discountLable.font = [UIFont systemFontOfSize:12];
    self.discountLable.textColor = [UIColor redColor];
    
    self.moneylable = [[UILabel alloc] init];
    [self.view addSubview:self.moneylable];
    self.moneylable.font = [UIFont systemFontOfSize:12];
    [_moneylable release];
    self.moneylable.textColor = [UIColor redColor];


}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.view.frame = CGRectMake(0, 0, WIDTH, HEIFGT );
    self.tuImageView.frame = CGRectMake(WIDTH / 18.75, HEIFGT / 133.42 + 5, WIDTH - WIDTH / 9.375,HEIFGT - 10 );
    self.aimLable.frame = CGRectMake(WIDTH / 17, HEIFGT / 5.55, WIDTH - WIDTH / 7.5, HEIFGT / 3.6);
    self.discountLable.frame = CGRectMake(WIDTH / 15, HEIFGT / 1.21, WIDTH / 10, HEIFGT / 11);
    self.moneylable.frame = CGRectMake(WIDTH - WIDTH / 4.3, HEIFGT / 1.21, WIDTH / 6, HEIFGT / 11);
    
    
}

#pragma mark -  Setter Method
- (void)setModel:(HYCRecommendMovie *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
        
        _aimLable.text = _model.title;
        
        
        NSLog(@"%@", _model.priceoff);
        _discountLable.text = _model.priceoff;


        NSString *str = [_model.price stringByReplacingOccurrencesOfString:@"<em>" withString:@""];
        NSString *str1 = [str stringByReplacingOccurrencesOfString:@"</em>" withString:@""];
        
        
        [_tuImageView sd_setImageWithURL:[NSURL URLWithString:_model.photo] placeholderImage:[UIImage imageNamed:@"zw.png"]];
        
        _moneylable.text = str1;
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
